package com.base.system.base.db.orders;

import javax.persistence.criteria.*;

public class AscOrder implements OrderBy {

    private final String property;
    private final JoinType joinType;

    public AscOrder(String property, JoinType joinType) {
        this.property = property;
        this.joinType = joinType;
    }

    @Override
    public Order toOrder(Root root, CriteriaQuery cq, CriteriaBuilder cb) {
        String attr = getProperty(property);
        From from = getFrom(property, root);
        return cb.asc(from.get(attr));
    }
}
